using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using DefLib;

namespace GameUI
{
    public class Sprite
    {
        List<Texture2D> lt2d_Interface;
        int _count;
        float _x;

        public float X
        {
            get { return _x; }
            set { _x = value; }
        }
        float _y;

        public float Y
        {
            get { return _y; }
            set { _y = value; }
        }
        int _width;

        public int Width
        {
            get { return _width; }
            set { _width = value; }
        }
        int _height;

        public int Height
        {
            get { return _height; }
            set { _height = value; }
        }
        public Sprite Clone(float x,float y,int w,int h)
        {
            Sprite Sp_clone = new Sprite();
            Sp_clone.Create(this.lt2d_Interface, 
                x>0?x:_x, 
                y>0?y:_y,
                w>0?w:_width,
                h>0?h:_height);
            return Sp_clone;
        }
        public void Create(List<Texture2D> lt_in,float x,float y,int wi,int he)
        {
            lt2d_Interface = lt_in;
            _count = 0;
            _x = x;
            _y = y;
            _width = wi;
            _height = he;
        }
        public void Update(int n_count,float x, float y, int wi, int he)
        {
            if((0<=n_count)&&(n_count<lt2d_Interface.Count))
                _count = n_count;
            _x = x;
            _y = y;
            _width = wi;
            _height = he;
        }
        public void Draw(SpriteBatch spritebatch)
        {
           
            spritebatch.Draw(lt2d_Interface[_count],
                new Rectangle((int)_x-ViewFrame.window.X
                    ,(int) _y-ViewFrame.window.Y
                    , _width, _height), Color.White);
        }
    }
}
